define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'superdata/account/index' + location.search,
                    add_url: 'superdata/account/add',
                    edit_url: 'superdata/account/edit',
                    // del_url: 'superdata/account/del',
                    // multi_url: 'superdata/account/multi',
                    // import_url: 'superdata/account/import',
                    table: 'account',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        // {checkbox: true},
                        {field:'no',title:__('序号'),operate:false,
                            formatter:function(value,row,index){
                            var pageSize=table.bootstrapTable('getOptions').pageSize;//获取每页显示的数量
                            var pageNumber=table.bootstrapTable('getOptions').pageNumber;//获取当前是第几面
                            return pageSize * (pageNumber - 1) + index +1 ;
                            }
                        },
                        {field: 'username', title: __('Username'), align: 'left', operate: 'LIKE %...%', placeholder: '用户名搜索'},
                        {field: 'nickname', title: __('Nickname'), align: 'left', operate: 'LIKE %...%', placeholder: '昵称搜索'},
                        {field: 'mobile', title: __('Mobile')},
                        {field: 'activity_count', title: __('Activity_count'),operate:false},
                        {field: 'series_count', title: __('Series_count'),operate:false},
                        {field: 'total_income', title: __('Total_income'),operate:false},
                        {field: 'order_count', title: __('Order_count'),operate:false},
                        // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});